#include "mainwindow.h"
#include <QDebug>
#include "playimageswidget.h"

MainWindow::MainWindow(QWidget *parent)
    : QWidget(parent)
{
    this->setWindowFlags(Qt::FramelessWindowHint);

    initUI();
}

MainWindow::~MainWindow()
{

}

void MainWindow::initUI()
{
    updateSize();

    this->setAutoFillBackground(true);
    QPalette palette = this->palette();
    palette.setColor(QPalette::Window, Qt::black);
    this->setPalette(palette);

    PlayImagesWidget *imgWidght = new PlayImagesWidget("/home/xll/Desktop/images2", this);
    imgWidght->setLoopPlay(true);
    imgWidght->setScale(0.8);
    imgWidght->move((this->width() - imgWidght->width()) / 2, (this->height() - imgWidght->height() ) / 2);
    imgWidght->play();
    qDebug() << imgWidght->width() << imgWidght->height();
}

void MainWindow::updateSize()
{
    QScreen *screen = qApp->primaryScreen();
    this->setFixedSize(screen->size());
    qDebug() << "primaryscreen:" << screen->name() << screen->size();
}

void MainWindow::mouseDoubleClickEvent(QMouseEvent *event)
{
    Q_UNUSED(event);
    qApp->quit();
}
